package com.shop.cereshop.app.page.pet;

import com.shop.cereshop.commons.domain.pet.CerePetInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDate;
import java.time.Period;

@Data
@ApiModel(value = "PetInfoVO", description = "宠物信息")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class PetInfoVO extends CerePetInfo {

    @ApiModelProperty("宠物年龄")
    private Integer age;

    public Integer getAge() {
        if (getPetBirthday() == null) {
            return null;
        }
        return Period.between(getPetBirthday(), LocalDate.now()).getYears();
    }
}
